home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000177_icon-group-sender _Thu Jun 16 12:27:04 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
2KB
Received: by cheltenham.cs.arizona.edu; Thu, 16 Jun 1994 15:11:29 MST
Date: Thu, 16 Jun 94 12:27:04 PDT
From: eric@star-semi.com (Eric Armstrong)
Message-Id: <9406161927.AA07961@star-semi.com>
To: icon-group@cs.arizona.edu
Subject: booleans, enumerations, globals
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
I am just beginning to come to grips with the wonderful expressive power
of Icon's expression evaluation, so I'm learning to combine expressions in
ways that implement algorithmns succinctly. But some parts of my code are
beginning to look pretty ugly. I'm wondering what idioms you guys use to:
a. Do a simple boolean test, like
if a=true -or- if a=false
At the moment, I'm doing a horrible global definition of true
and false, and initializing them at the beginning of the main
routine. Incredibly ugly. Immediately begins to obscure an
otherwise comprehensible algorithm.
b. Create something like a Pascal enumeration type
Days of the week, for example. I create a list of strings:
["Mon", "Tue", ...] but then I index it by a number (weekday[2]).
How would it be possible to index it as weekday[Tue]?
c. initialize globals
The "initial" clause is really excellent in procedures. Its primary
value is that it lets me put initial values in the same place that
the variables are used, instead of miles away in some initialization
routine. But every time I need a global, I wind up doing that
same old initialization schtick. (More than I would like to, as
a result of issues #1 and #2.)
Hopefully, there are some idomatic themes that will alleviate these problems.
I look forward to your replies.